package com.example.juc.lock;

import java.util.concurrent.TimeUnit;

public class TestSpln {
    public static void main(String[] args) throws InterruptedException {

        SplnLockDemo lock = new SplnLockDemo();


        new Thread(()->{
            lock.myLock();
            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            } finally {
                lock.myUnlock();
            }
        },"A").start();

        TimeUnit.SECONDS.sleep(2);

        new Thread(()->{
            lock.myLock();
            try {

            }finally {
                lock.myUnlock();
            }
        },"B").start();

    }
}
